// pages/consumption/consumption.js
import {
  getRecords
} from '../../../utils/networkRequest.js'
Page({

  /**
   * 页面的初始数据
   */
  data: {

    list: [],
    currentTab: "",
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    
  },
  onShow:function(){
    let self = this;
    getRecords("", (r) => {
      if (r.code == 0) {
        self.setData({
          list: r.data
        })
      }
      console.log(r)
    })
  },
  //跳转至评价
  goEvaluate: function(e) {
    let mid = e.currentTarget.dataset.mid; 
    let rid = e.currentTarget.dataset.rid; 
    wx.navigateTo({
      url: '../evaluate/evaluate?mid=' + mid + "&rid=" + rid,
    })
  },
  //跳转至订单详情
  onOrderDetail: function(e) {
    debugger;
    let id = e.currentTarget.dataset.id
    wx.navigateTo({
      url: '../orderDetail/orderDetail?id=' + id,
    })
  },
  changeTab: function(e) {
let self =this;
    let curid = e.currentTarget.dataset.curid;

    getRecords(curid, (r) => {
      if (r.code == 0) {
        self.setData({
          list: r.data,
          currentTab: curid
        })
      }
      console.log(r)
    })

  }
})